<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {margin:0; padding: 0;}
        ul {
            list-style-type: none;
        }
        .box {
            width: 400px;
            height: 300px;
            border: 1px solid #ccc;
            margin: 100px auto;
            overflow: hidden;
        }
        .hd {
            height: 45px;
        }
        .hd span {
            display:inline-block;
            width: 90px;
            background-color: pink;
            line-height: 45px;
            text-align: center;
            cursor: pointer;
        }
        .hd span.current {
            background-color: skyblue;
        }
        .bd div {
            height: 255px;
            background-color: skyblue;
            display: none;
        }
        .bd div.current {
            display: block;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="hd" id="hd">
            <span class="current">体育</span>
            <span>娱乐</span>
            <span>新闻</span>
            <span>综合</span>
        </div>
        <div class="bd" id="bd">
            <div class="current">我是体育模块</div>
            <div>我是娱乐模块</div>
            <div>我是新闻模块</div>
            <div>我是综合模块</div>
        </div>
    </div>
    <script src="js/common.js"></script>
    <script>
       var hd = my$("hd");
    //    console.log(hd);
       var spans = hd.getElementsByTagName("span");
    //    console.log(spans);
       var bd = my$("bd");
       var divs = bd.getElementsByTagName("div");
    for(var i = 0;i<spans.length;i++){
        spans[i].index = i;
        spans[i].onmouseover = function(){
            this.className="current";
            divs[this.index].className="current";
            }
        spans[i].onmouseout = function(){
            this.className = "";
            divs[this.index].className = "";
            } 
       }
    
        

    </script>   
</body>
</html>